"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var NotificationComponent = /** @class */ (function () {
    function NotificationComponent() {
        this.duration = 5000; // 显示时间，为0时不关闭
        this.isShow = true;
        this.promptIsShow = new core_1.EventEmitter();
    }
    NotificationComponent.prototype.ngOnInit = function () {
        this.setTitle();
    };
    // 设置头
    NotificationComponent.prototype.setTitle = function () {
        if (!this.title) {
            switch (this.type) {
                case 'success':
                    this._title = '成功';
                    break;
                case 'warning':
                    this._title = '警告';
                    break;
                case 'error':
                    this._title = '错误';
                    break;
                case 'info':
                    this._title = '提示';
                    break;
            }
        }
        else {
            this._title = this.title;
        }
    };
    NotificationComponent.prototype.ngDoCheck = function () {
        if (this.isShow === true) {
            this._isShow = this.isShow;
            this.setTitle();
            this.delayed();
        }
    };
    // 设置自动关闭隐藏的时间
    NotificationComponent.prototype.delayed = function () {
        var _this = this;
        if (this.duration != 0) {
            setTimeout(function () {
                _this._isShow = false;
                _this.promptIsShow.emit(_this._isShow);
            }, this.duration);
        }
    };
    // 关闭提示框
    NotificationComponent.prototype.closePrompt = function () {
        this._isShow = false;
        this.promptIsShow.emit(this._isShow);
    };
    __decorate([
        core_1.Input()
    ], NotificationComponent.prototype, "title", void 0);
    __decorate([
        core_1.Input()
    ], NotificationComponent.prototype, "type", void 0);
    __decorate([
        core_1.Input()
    ], NotificationComponent.prototype, "message", void 0);
    __decorate([
        core_1.Input()
    ], NotificationComponent.prototype, "duration", void 0);
    __decorate([
        core_1.Input()
    ], NotificationComponent.prototype, "isShow", void 0);
    __decorate([
        core_1.Output()
    ], NotificationComponent.prototype, "promptIsShow", void 0);
    NotificationComponent = __decorate([
        core_1.Component({
            selector: 'app-notification',
            templateUrl: 'notification.component.html',
            styleUrls: ['notification.component.scss'],
            providers: []
        })
    ], NotificationComponent);
    return NotificationComponent;
}());
exports.NotificationComponent = NotificationComponent;
